<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class SysConfig extends Model
{
    protected $guarded = [];
    public $timestamps = false;

    public function getSellCartConfig()
    {
        $config = $this->newQuery()->where('type',1)->first();
        $config_book_num = 0;
        $config_total_price = 0;
        if(!empty($config) && !empty($config->configs))
        {
            $config_arr = json_decode($config->configs,true);
            $config_book_num = isset($config_arr['book_num']) ? $config_arr['book_num'] : 0;
            $config_total_price = isset($config_arr['total_price']) ? $config_arr['total_price'] : 0;
        }

        $result = [
            'config_book_num'       => $config_book_num,
            'config_total_price'    => $config_total_price,
        ];
        return $result;
    }
}
